
package com.rt.schedulenew.web;

import com.rt.schedulebase.dto.ExamScheduleActDto;
import com.rt.schedulebase.dto.ExamSyslogDto;
import com.rt.schedulenew.api.IExamScheduleActService;
import com.rt.schedulenew.api.IExamSyslogService;
import com.rt.schedulenew.utils.base.ConstantsUtil;
import com.rt.schedulenew.utils.global.JsonResult;
import com.rt.schedulenew.utils.global.JsonResultUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping({"/log"})
public class LogController {
    @Autowired
    private IExamScheduleActService examScheduleActService;
    @Autowired
    private IExamSyslogService examSyslogService;

    @PostMapping({"/examScheduleAct/list"})
    public JsonResult examScheduleActList(@RequestBody ExamScheduleActDto dto) {
        return examScheduleActService.examScheduleActList(dto);
    }

    @PostMapping({"/examSysLog/list"})
    public JsonResult getExamSysLogList(@RequestBody ExamSyslogDto dto) {
        if (StringUtils.isBlank(dto.getModuleName())) {
            List<String> list = new ArrayList<String>();
            list.add("DICT_SCHEDULE_APM_COMMON");
            list.add("DICT_SCHEDULE_APM_WEEK");
            list.add("DICT_SCHEDULE_APM_DATE");
            list.add("DICT_SCHEDULE_REGULAR_DEF");
            dto.setModuleNames(list);
        }
        return examSyslogService.getExamSysLogList(dto);
    }

    /**
     * 字典操作日志
     *
     * @param dto
     * @return
     */
    @PostMapping({"/dictionary/list"})
    public JsonResult dictLogList(@RequestBody ExamSyslogDto dto) {
        if (StringUtils.isBlank(dto.getModuleName())) {
//            List<String> list = new ArrayList<String>();
//            list.add("DICT_SCHEDULE_QUEUE");
//            list.add("DICT_EXAM_ITEM");
//            list.add("DICT_REMINDER");
//            list.add("DICT_SCHEDULE_REGULAR_DEF");
//            list.add("ITEM_GROUP");

            dto.setModuleNames(ConstantsUtil.ModuleName.getDictModuleName());
        }
        return JsonResultUtil.success("成功", examSyslogService.getExamSysLogList(dto));
    }

//    public static void main(String[] args) {
//        ExamSchedule es = new ExamSchedule();
//        es.setScheduledDate("2020-06-22");
//        es.setScheduler("张三");
//        es.setMemo((String) null);
//        ExamSchedule es2 = new ExamSchedule();
//        es2.setScheduledDate("2020-06-23");
//        es2.setScheduler("李四");
//        es2.setMemo("这里是备注1");
//        String str = LogUtil.compareObject((Object) es, (Object) es2);
//        System.out.println(str);
//    }
}
